using System;
using System.Collections.Generic;
using System.Text;
using Shc.Sql;
using Shc.Json;
namespace CLZ.Data
{
	public static class TableArea
	{
		public const string Table = "Area";
		public const string AreaID = "AreaID";
		public const string RegionID = "RegionID";
		public const string AreAreaID = "Are_AreaID";
		public const string AreaName = "AreaName";
	}
	
	[Serializable]
	public class BaseArea
		: IDbSessionEntity, IJsonClass
	{
		int m_AreaID;
		/// <summary>
        /// 片区表ID
        /// </summary>
        public int AreaID
        {
            get { return m_AreaID; }
            set { m_AreaID = value; }
        }
		
		int? m_RegionID;
		/// <summary>
        /// 县/区表ID
        /// </summary>
        public int? RegionID
        {
            get { return m_RegionID; }
            set { m_RegionID = value; }
        }
		
		int? m_AreAreaID;
		/// <summary>
        /// 片区表ID
        /// </summary>
        public int? AreAreaID
        {
            get { return m_AreAreaID; }
            set { m_AreAreaID = value; }
        }
		
		string m_AreaName;
		/// <summary>
        /// 片区名称
        /// </summary>
        public string AreaName
        {
            get { return m_AreaName; }
            set { m_AreaName = value; }
        }
		
		
		#region IDbSessionEntity Members
		public void ReadDBData(RowDataReader reader)
        {
            m_AreaID = reader[TableArea.AreaID];
            m_RegionID = reader[TableArea.RegionID];
            m_AreAreaID = reader[TableArea.AreAreaID];
            m_AreaName = reader[TableArea.AreaName];
        }
		
		public void WriteDBData(RowDataWriter writer)
        {
            writer.SetPrimaryKey(TableArea.AreaID, PrimaryKeyType.Identity, AreaID);
			writer[TableArea.RegionID] = RegionID;
			writer[TableArea.AreAreaID] = AreAreaID;
			writer[TableArea.AreaName] = AreaName;
        }

        public void SetIdentityAfterInsert(DBObject idd)
        {
            m_AreaID = idd;
        }
		
		public string TableName
        {
            get { return TableArea.Table; }
        }
		#endregion
		
		#region IJsonClass Members

        public void JsonDeSerializeObj(JsonHashTable hashToRead)
        {
             m_AreaID = hashToRead["AreaID"];
			 
             m_RegionID = hashToRead["RegionID"];
			 
             m_AreAreaID = hashToRead["AreAreaID"];
			 
             m_AreaName = hashToRead["AreaName"];
			 
        }

        public void JsonSerializeObj(JsonHashTable hashToFill)
        {
            hashToFill["AreaID"] = AreaID;
			 
            hashToFill["RegionID"] = RegionID;
			 
            hashToFill["AreAreaID"] = AreAreaID;
			 
            hashToFill["AreaName"] = AreaName;
			 
        }

        #endregion
		
	}
}
